//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include <Eic.h>
#include <uListePays.h> //Pour TListePays
#include "CAdressePanel.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
#define HEIGHT_CEDIT   21

#define ESPACEMENT_DEBUT 10 //Espace entre le 1er label de la ligne et le CEdit
#define ESPACEMENT_ED_ED  2 //Espace entre deux edit
#define ESPACEMENT_LAB_ED 5 //Espace entre un label et un Cedit

#define NB_LIGNES_FORMAT1        4
#define NB_LIGNES_FORMAT2        4
#define NB_LIGNES_FORMAT3        5
#define NB_LIGNES_FORMAT4        4
#define NB_LIGNES_FORMAT_TDFC    5

//Calcul la propriété Right d'un composant
#define GET_RIGHT(a) (##a->Left + ##a->Width)
//Calcul le width pour que le composant aille jusqu'au bord droit
#define GET_WIDTH_D(a) (Width - ##a->Left - Bord)

//---------------------------------------------------------------------------
#define MODULE_TAG 2550
//---------------------------------------------------------------------------

const char *lstTypeBis[ecnv_TAILLE]={NULL,"BIS","TER","QUATER"};
const char *lstTypeBis2[ecnv_TAILLE]={NULL,"B","T","Q"};
const char *lstTypeBis3[ecnv_TAILLE]={NULL,"Bis","Ter","Qua"};

//---------------------------------------------------------------------------
// ValidCtrCheck est utilisé est utilisé pour être sûr que les composants créés n'ont
// aucune fonction virtuelle pure.
//

static inline void ValidCtrCheck(CAdressePanel *)
{
  new CAdressePanel(NULL);
}
//---------------------------------------------------------------------------
namespace Cadressepanel
{
  void __fastcall PACKAGE Register()
  {
    TComponentClass classes[1] = {__classid(CAdressePanel)};
    RegisterComponents("EIC Ctrlstd", classes, 0);
  }
}

//---------------------------------------------------------------------------
//                     CLASSES POUR LES FORMATS D'ADRESSE
//---------------------------------------------------------------------------
__fastcall TAdresseDetaillee::TAdresseDetaillee()
{
szNumero      [0] =
szBis         [0] =
szTypeVoie    [0] =
szLibelleVoie [0] =
szBatiment    [0] =
szEscalier    [0] =
szEtage       [0] =
szNumLot      [0] =
szLieuDit     [0] =
szComplement  [0] =
szBoitePostale[0] =
szCodePostal  [0] =
szVille       [0] =
szCedex       [0] = '\0';
nPays             = 0;
}

void __fastcall TAdresseDetaillee::operator= (const TAdresseDetaillee &Classe)
{
  strncpy(szNumero, Classe.szNumero, NB_CAR_NUM);
  strncpy(szBis, Classe.szBis, NB_CAR_BIS);
  strncpy(szTypeVoie, Classe.szTypeVoie, NB_CAR_TYPE_VOIE);
  strncpy(szLibelleVoie, Classe.szLibelleVoie, NB_CAR_LIBELLE_VOIE);
  strncpy(szBatiment, Classe.szBatiment, NB_CAR_BAT);
  strncpy(szEscalier, Classe.szEscalier, NB_CAR_ESC);
  strncpy(szEtage, Classe.szEtage, NB_CAR_ETG);
  strncpy(szNumLot, Classe.szNumLot, NB_CAR_LOT);
  strncpy(szLieuDit, Classe.szLieuDit, NB_CAR_LIEU_DIT);
  strncpy(szComplement, Classe.szComplement, NB_CAR_COMPL);
  strncpy(szBoitePostale, Classe.szBoitePostale, NB_CAR_BP);
  strncpy(szCodePostal, Classe.szCodePostal, NB_CAR_CP);
  strncpy(szVille, Classe.szVille, NB_CAR_VILLE);
  strncpy(szCedex, Classe.szCedex, NB_CAR_CEDEX);
  nPays = Classe.nPays;
}

/*******************************************************************************

Fonction :

Paramètres d'entrée :

Paramètres de sortie :

Valeur retournée :
*******************************************************************************/
__fastcall TAdresseFormat1::TAdresseFormat1()
{
aAdresseLigne1 =
aAdresseLigne2 =
aAdresseLigne3 =
aCodePostal    =
aVille         = EmptyStr;
}
void __fastcall  TAdresseFormat1::operator= (const TAdresseFormat1 &Classe)
{
  aAdresseLigne1 = Classe.aAdresseLigne1;
  aAdresseLigne2 = Classe.aAdresseLigne2;
  aAdresseLigne3 = Classe.aAdresseLigne3;
  aCodePostal    = Classe.aCodePostal;;
  aVille         = Classe.aVille;
}
/*******************************************************************************

Fonction :

Paramètres d'entrée :

Paramètres de sortie :

Valeur retournée :
*******************************************************************************/
__fastcall  TAdresseFormat2::TAdresseFormat2()
{
  aLieuDit    =
  aNum        =
  aNature     =
  aNomVoie    =
  aComplement =
  aCodePostal =
  aVille      = EmptyStr;
}
void __fastcall  TAdresseFormat2::operator= (const TAdresseFormat2 &Classe)
{
  aLieuDit    = Classe.aLieuDit;
  aNum        = Classe.aNum;
  aNature     = Classe.aNature;
  aNomVoie    = Classe.aNomVoie;
  aComplement = Classe.aComplement;
  aCodePostal = Classe.aCodePostal;
  aVille      = Classe.aVille;
}
/*******************************************************************************

Fonction :

Paramètres d'entrée :

Paramètres de sortie :

Valeur retournée :
*******************************************************************************/
__fastcall  TAdresseFormat3::TAdresseFormat3()
{
  aResidence  =
  aBatiment   =
  aEscalier   =
  aEtage      =
  aNumLot     =
  aAdresse    =
  aCodePostal =
  aVille      = EmptyStr;
}

void __fastcall  TAdresseFormat3::operator= (const TAdresseFormat3 &Classe)
{
  aResidence  = Classe.aResidence;
  aBatiment   = Classe.aBatiment;
  aEscalier   = Classe.aEscalier;
  aEtage      = Classe.aEtage;
  aNumLot     = Classe.aNumLot;
  aAdresse    = Classe.aAdresse;
  aCodePostal = Classe.aCodePostal;
  aVille      = Classe.aVille;
}
/*******************************************************************************

Fonction :

Paramètres d'entrée :

Paramètres de sortie :

Valeur retournée :
*******************************************************************************/
__fastcall  TAdresseFormat4::TAdresseFormat4()
{
  aLieuDit    =
  aNum        =
  aNature     =
  aNomVoie    =
  aBP         =
  aComplement =
  aCodePostal =
  aVille      = EmptyStr;
}

void __fastcall  TAdresseFormat4::operator= (const TAdresseFormat4 &Classe)
{
  aLieuDit    = Classe.aLieuDit;
  aNum        = Classe.aNum;
  aNature     = Classe.aNature;
  aNomVoie    = Classe.aNomVoie;
  aBP         = Classe.aBP;
  aComplement = Classe.aComplement;
  aCodePostal = Classe.aCodePostal;
  aVille      = Classe.aVille;
}
/*******************************************************************************

Fonction :

Paramètres d'entrée :

Paramètres de sortie :

Valeur retournée :
*******************************************************************************/
__fastcall  TAdresseFormatTDFC::TAdresseFormatTDFC()
{
  aLieuDit    =
  aComplement =
  aNum        =
  aNature     =
  aNomVoie    =
  aBP         =
  aCodePostal =
  aVille      = EmptyStr;
  iIndexPays  = 0;
}

void __fastcall  TAdresseFormatTDFC::operator= (const TAdresseFormatTDFC &Classe)
{
  aLieuDit    = Classe.aLieuDit;
  aComplement = Classe.aComplement;
  aNum        = Classe.aNum;
  aNature     = Classe.aNature;
  aNomVoie    = Classe.aNomVoie;
  aBP         = Classe.aBP;
  aCodePostal = Classe.aCodePostal;
  aVille      = Classe.aVille;
  iIndexPays  = Classe.iIndexPays;
}

//---------------------------------------------------------------------------
//                    CLASSE POUR GERER LES CODES POSTAUX
//---------------------------------------------------------------------------
__fastcall CCodePostal::CCodePostal(TComponent* Owner) : CEdit(Owner)
{
m_bCPInternational = false;
}

//---------------------------------------------------------------------------
// Affiche le Code Postal sur 5 chiffres
//---------------------------------------------------------------------------
void __fastcall CCodePostal::DoExit()
{
  try
  {
  if(!Text.IsEmpty() && !m_bCPInternational)
     Text = AnsiString().sprintf("%05u", Text.ToInt());

  inherited::DoExit();
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(12), e);
  }
}
//------------------------------------------------------------------------------
void __fastcall CCodePostal::SetCPInternational(bool bCPInternational)
{
  try
  {
    m_bCPInternational = bCPInternational;
    if(!m_bCPInternational)
       {
       Filtres << feNumerique;
       MaxLength = 5;
       }
    else
       {
       Filtres >> feNumerique;
       MaxLength = 17;
       }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(15), e);
  }
}

//---------------------------------------------------------------------------
//                          CLASSE "CAdressePanel"
//---------------------------------------------------------------------------

/***  Méthodes publiques ***/
__fastcall CAdressePanel::CAdressePanel(TComponent* Owner) : TCustomPanel(Owner)
{
  try
  {
    Height = 120;
    Width  = 400;

    Caption = " ";

    nTailleLabel = 0;

    Edit1 =
    Edit2 =
    Edit3 =
    Edit4 =
    Edit5 =
    Edit6 =
    Edit7 =
    Edit8 = NULL;

    eCP         = new CCodePostal(this);
    eCP->Parent = this;

    cbBis =
    cbPays = NULL;

    Label1 =
    Label2 =
    Label3 =
    Label4 =
    Label5 =
    Label6 =
    Label7 =
    Label8 = NULL;

    SetTypeFormat(FORMAT_1);
    m_bAfficheLibelle   = true;
    m_bFormatTDFCacPays = true;
    m_bReadOnly = false;
    m_bEnabled  = false;

    Affichage();

    OnResize = MyResize;
    OnCanResize = MyCanResize;

  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1000), e);
  }
}
//----------------------------------------------------------------------------
__fastcall CAdressePanel::~CAdressePanel()
{
  try
  {
    SuppressionEdit();
    SuppressionLabel();
    delete eCP;      eCP = NULL;
    delete cbBis;    cbBis = NULL;
    delete cbPays;   cbPays = NULL;
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1010), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::Vider(void)
{
  try
  {
    switch(m_nFormat)
    {
      case FORMAT_1 :
        Edit1->Text  = EmptyStr;
        Edit2->Text  = EmptyStr;
        Edit3->Text  = EmptyStr;
        eCP->Text    = EmptyStr;
        Edit4->Text  = EmptyStr;
        break;
      case FORMAT_2 :
        Edit1->Text  = EmptyStr;
        Edit2->Text  = EmptyStr;
        cbBis->Text  = EmptyStr;
        Edit3->Text  = EmptyStr;
        Edit4->Text  = EmptyStr;
        eCP->Text    = EmptyStr;
        Edit5->Text  = EmptyStr;
        break;
      case FORMAT_3 :
        Edit1->Text  = EmptyStr;
        Edit2->Text  = EmptyStr;
        Edit3->Text  = EmptyStr;
        Edit4->Text  = EmptyStr;
        Edit5->Text  = EmptyStr;
        Edit6->Text  = EmptyStr;
        eCP->Text    = EmptyStr;
        Edit7->Text  = EmptyStr;
        break;
      case FORMAT_4 :
        Edit1->Text  = EmptyStr;
        Edit2->Text  = EmptyStr;
        cbBis->Text  = EmptyStr;
        Edit3->Text  = EmptyStr;
        Edit4->Text  = EmptyStr;
        Edit5->Text  = EmptyStr;
        eCP->Text    = EmptyStr;
        Edit6->Text  = EmptyStr;
        break;
      case FORMAT_TDFC :
        Edit1->Text  = EmptyStr;
        Edit2->Text  = EmptyStr;
        Edit3->Text  = EmptyStr;
        cbBis->Text  = EmptyStr;
        Edit4->Text  = EmptyStr;
        Edit5->Text  = EmptyStr;
        eCP->Text    = EmptyStr;
        Edit6->Text  = EmptyStr;
        if(m_bFormatTDFCacPays)
        {
          cbPays->Text = EmptyStr;
          Edit7->Text  = EmptyStr;
        }
        break;
      default :
        ASSERT(false);
        break;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1020), e);
  }
}

//---------------------------------------------------------------------------
//           Fonctions d'affichage de données dans le CAdressePanel
//                        selon le format sélectionné
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::RemplirPanel(const TAdresseFormat1 &_sAdr1)
{
  try
  {
    ASSERT(m_nFormat == FORMAT_1);
    if(!ComponentState.Contains(csDesigning))
    {
      Edit1->Text = _sAdr1.aAdresseLigne1;
      Edit2->Text = _sAdr1.aAdresseLigne2;
      Edit3->Text = _sAdr1.aAdresseLigne3;
      eCP->Text   = _sAdr1.aCodePostal;
      Edit4->Text = _sAdr1.aVille;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1030), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::RemplirPanel(const TAdresseFormat2 &_sAdr2)
{
  try
  {
    ASSERT(m_nFormat == FORMAT_2);
    if(!ComponentState.Contains(csDesigning))
    {
      Edit1->Text      = _sAdr2.aLieuDit;
      Edit2->Text      = _sAdr2.aNum;
      cbBis->ItemIndex = AffecterCBBis(_sAdr2.aNature);//cbBis->Items->IndexOf(_sAdr2.aNature);
      Edit3->Text      = _sAdr2.aNomVoie;
      Edit4->Text      = _sAdr2.aComplement;
      eCP->Text        = _sAdr2.aCodePostal;
      Edit5->Text      = _sAdr2.aVille;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1040), e);
  }
}

enum eComplementNoVoie __fastcall CAdressePanel::AffecterCBBis(const AnsiString &Nature)
{
  for(enum eComplementNoVoie i = ecnv_FIRST;i <= ecnv_LAST;i++)
    if (AnsiSameText(Nature,lstTypeBis[i]) ||
        AnsiSameText(Nature,lstTypeBis2[i]) ||
        AnsiSameText(Nature,lstTypeBis3[i]))
      return i;
  return ecnv_RIEN;
}
AnsiString __fastcall CAdressePanel::StrComplementNoVoie(const AnsiString &Nature)
{
  for(enum eComplementNoVoie i = ecnv_FIRST;i <= ecnv_LAST;i++)
    if (AnsiSameText(Nature,lstTypeBis[i]) ||
        AnsiSameText(Nature,lstTypeBis2[i]) ||
        AnsiSameText(Nature,lstTypeBis3[i]))
      return LowerCase(lstTypeBis[i]);
  return EmptyStr;
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::RemplirPanel(const TAdresseFormat3 &_sAdr3)
{
  try
  {
    ASSERT(m_nFormat == FORMAT_3);
    if(!ComponentState.Contains(csDesigning))
    {
      Edit1->Text = _sAdr3.aResidence;
      Edit2->Text = _sAdr3.aBatiment;
      Edit3->Text = _sAdr3.aEscalier;
      Edit4->Text = _sAdr3.aEtage;
      Edit5->Text = _sAdr3.aNumLot;
      Edit6->Text = _sAdr3.aAdresse;
      eCP->Text   = _sAdr3.aCodePostal;
      Edit7->Text = _sAdr3.aVille;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1050), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::RemplirPanel(const TAdresseFormat4 &_sAdr4)
{
  try
  {
    ASSERT(m_nFormat == FORMAT_4);
    if(!ComponentState.Contains(csDesigning))
    {
      Edit1->Text      = _sAdr4.aLieuDit;
      Edit2->Text      = _sAdr4.aNum;
      cbBis->ItemIndex = AffecterCBBis(_sAdr4.aNature);//cbBis->Items->IndexOf(_sAdr4.aNature);
      Edit3->Text      = _sAdr4.aNomVoie;
      Edit4->Text      = _sAdr4.aBP;
      Edit5->Text      = _sAdr4.aComplement;
      eCP->Text        = _sAdr4.aCodePostal;
      Edit6->Text      = _sAdr4.aVille;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1060), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::RemplirPanel(const TAdresseFormatTDFC &_sAdrTDFC)
{
  try
  {
    ASSERT(m_nFormat == FORMAT_TDFC);
    if(!ComponentState.Contains(csDesigning))
    {
      Edit1->Text      = _sAdrTDFC.aLieuDit;
      Edit2->Text      = _sAdrTDFC.aComplement;
      Edit3->Text      = _sAdrTDFC.aNum;
      if (!_sAdrTDFC.aNature.IsEmpty())
      {
        cbBis->ItemIndex = AffecterCBBis(_sAdrTDFC.aNature);/*cbBis->Items->IndexOf(_sAdrTDFC.aNature.LowerCase());
        if (cbBis->ItemIndex == -1)
        {
          //Regarder si on a B, T ou Q
          for(int i = 0; *lstTypeBis2[i] != '\0'; i++)
            if (_sAdrTDFC.aNature == lstTypeBis2[i])
              cbBis->ItemIndex = i + 1;
        }
        if (cbBis->ItemIndex == -1)
        {
          //Regarder si on a Bis, Ter ou Qua
          for(int i = 0; *lstTypeBis3[i] != '\0'; i++)
            if (_sAdrTDFC.aNature == lstTypeBis3[i])
              cbBis->ItemIndex = i + 1;
        }*/
      }
      Edit4->Text      = _sAdrTDFC.aNomVoie;
      Edit5->Text      = _sAdrTDFC.aBP;
      eCP->Text        = _sAdrTDFC.aCodePostal;
      Edit6->Text      = _sAdrTDFC.aVille;
      if(m_bFormatTDFCacPays)
      {
        TListePays cListePays;
        cbPays->Text = EmptyStr;
        Edit7->Text  = EmptyStr;
        int index;
        for(index = 0; index< cbPays->Items->Count; index++)
          if ((int)cbPays->Items->Objects[index] == _sAdrTDFC.iIndexPays)
          {
            cbPays->ItemIndex = index;
            Edit7->Text       = cListePays.TabPays[index].aCodeISO;
            break;
          }
        for(index = 0; index<  cListePays.Count; index++)
          if (cListePays.TabPays[index].iID == _sAdrTDFC.iIndexPays)
          {
            Edit7->Text       = cListePays.TabPays[index].aCodeISO;
            break;
          }

        //cbPays->ItemIndex = _sAdrTDFC.iIndexPays;
        //   Edit7->Text       = cListePays.TabPays[_sAdrTDFC.iIndexPays].aCodeISO;
        //Edit7->Text       = cListePays.TabPays[index].aCodeISO;
      }
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1070), e);
  }
}

//---------------------------------------------------------------------------
//             Fonctions de récupération des données du CAdressePanel
//                         selon le format sélectionné
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::LirePanel(TAdresseFormat1 *_sAdr1) const
{
  try
  {
    ASSERT(m_nFormat == FORMAT_1);
    if(!ComponentState.Contains(csDesigning))
    {
      _sAdr1->aAdresseLigne1   = Edit1->Text;
      _sAdr1->aAdresseLigne2   = Edit2->Text;
      _sAdr1->aAdresseLigne3   = Edit3->Text;
      _sAdr1->aCodePostal      = eCP->Text;
      _sAdr1->aVille           = Edit4->Text;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1080), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::LirePanel(TAdresseFormat2 *_sAdr2) const
{
  try
  {
    ASSERT(m_nFormat == FORMAT_2);
    if(!ComponentState.Contains(csDesigning))
    {
      _sAdr2->aLieuDit     = Edit1->Text;
      _sAdr2->aNum         = Edit2->Text;
      _sAdr2->aNature      = cbBis->Text;
      _sAdr2->aNomVoie     = Edit3->Text;
      _sAdr2->aComplement  = Edit4->Text;
      _sAdr2->aCodePostal  = eCP->Text;
      _sAdr2->aVille       = Edit5->Text;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1090), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::LirePanel(TAdresseFormat3 *_sAdr3) const
{
  try
  {
    ASSERT(m_nFormat == FORMAT_3);
    if(!ComponentState.Contains(csDesigning))
    {
      _sAdr3->aResidence    = Edit1->Text;
      _sAdr3->aBatiment     = Edit2->Text;
      _sAdr3->aEscalier     = Edit3->Text;
      _sAdr3->aEtage        = Edit4->Text;
      _sAdr3->aNumLot       = Edit5->Text;
      _sAdr3->aAdresse      = Edit6->Text;
      _sAdr3->aCodePostal   = eCP->Text;
      _sAdr3->aVille        = Edit7->Text;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1100), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::LirePanel(TAdresseFormat4 *_sAdr4) const
{
  try
  {
    ASSERT(m_nFormat == FORMAT_4);
    if(!ComponentState.Contains(csDesigning))
    {
      _sAdr4->aLieuDit      = Edit1->Text;
      _sAdr4->aNum          = Edit2->Text;
      _sAdr4->aNature       = cbBis->Text;
      _sAdr4->aNomVoie      = Edit3->Text;
      _sAdr4->aBP           = Edit4->Text;
      _sAdr4->aComplement   = Edit5->Text;
      _sAdr4->aCodePostal   = eCP->Text;
      _sAdr4->aVille        = Edit6->Text;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1110), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::LirePanel(TAdresseFormatTDFC *_sAdrTDFC) const
{
  try
  {
    ASSERT(m_nFormat == FORMAT_TDFC);
    if(!ComponentState.Contains(csDesigning))
    {
      _sAdrTDFC->aLieuDit      = Edit1->Text;
      _sAdrTDFC->aComplement   = Edit2->Text;
      _sAdrTDFC->aNum          = Edit3->Text;
      _sAdrTDFC->aNature       = cbBis->Text;
      _sAdrTDFC->aNomVoie      = Edit4->Text;
      _sAdrTDFC->aBP           = Edit5->Text;
      _sAdrTDFC->aCodePostal   = eCP->Text;
      _sAdrTDFC->aVille        = Edit6->Text;
      if(m_bFormatTDFCacPays && cbPays->ItemIndex != -1)
        //_sAdrTDFC->iIndexPays       = cbPays->ItemIndex;
        _sAdrTDFC->iIndexPays       = (int) cbPays->Items->Objects[cbPays->ItemIndex];
      else
        _sAdrTDFC->iIndexPays       = TListePays::AUCUN_PAYS;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1120), e);
  }
}
//---------------------------------------------------------------------------
bool __fastcall CAdressePanel::GetAdresseValide()
{
  bool       bEstValide = true;
  AnsiString aVille, aCodePostal, aLieuDit, aComplement, aNomVoie;
  try
  {
    switch(m_nFormat)
    {
      case FORMAT_1:
        aLieuDit    = Edit1->Text;
        aNomVoie    = Edit2->Text;
        aComplement = Edit3->Text;
        aCodePostal = eCP->Text;
        aVille      = Edit4->Text;
        break;
      case FORMAT_2:
        aLieuDit    = Edit1->Text;
        aNomVoie    = Edit3->Text;
        aComplement = Edit4->Text;
        aCodePostal = eCP->Text;
        aVille      = Edit5->Text;
        break;
      case FORMAT_3:
        aNomVoie    = Edit6->Text;
        aCodePostal = eCP->Text;
        aVille      = Edit7->Text;
        break;
      case FORMAT_4:
        aLieuDit    = Edit1->Text;
        aNomVoie    = Edit3->Text;
        aComplement = Edit5->Text;
        aCodePostal = eCP->Text;
        aVille      = Edit6->Text;
        break;
      case FORMAT_TDFC:
        aLieuDit    = Edit1->Text;
        aComplement = Edit2->Text;
        aNomVoie    = Edit4->Text;
        aCodePostal = eCP->Text;
        aVille      = Edit6->Text;
        break;
    }
    if(   (aVille == EmptyStr)
       || (aCodePostal == EmptyStr)
       || ((aLieuDit == EmptyStr) && (aComplement == EmptyStr) && (aNomVoie == EmptyStr)) )
         bEstValide =  false;
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1130), e);
  }
  return bEstValide;
}
//---------------------------------------------------------------------------
bool __fastcall CAdressePanel::GetAdresseVide(void)
{
  bool bEstVide = true;
  try
  {
    switch(m_nFormat)
    {
      case FORMAT_1:
        {
          TAdresseFormat1 adr1;
          LirePanel(&adr1);
          bEstVide = (adr1.aAdresseLigne1.IsEmpty() && adr1.aAdresseLigne2.IsEmpty() && adr1.aAdresseLigne3.IsEmpty() &&
                      adr1.aCodePostal.IsEmpty() && adr1.aVille.IsEmpty());
        }
        break;
      case FORMAT_2:
        {
          TAdresseFormat2 adr2;
          LirePanel(&adr2);
          bEstVide = (adr2.aLieuDit.IsEmpty() && adr2.aNum.IsEmpty() && adr2.aNature.IsEmpty() && adr2.aNomVoie.IsEmpty() &&
                      adr2.aComplement.IsEmpty() && adr2.aCodePostal.IsEmpty() && adr2.aVille.IsEmpty());
        }
        break;
      case FORMAT_3:
        {
          TAdresseFormat3 adr3;
          LirePanel(&adr3);
          bEstVide = (adr3.aResidence.IsEmpty() && adr3.aBatiment.IsEmpty() && adr3.aEscalier.IsEmpty() &&
                      adr3.aEtage.IsEmpty() && adr3.aNumLot.IsEmpty() && adr3.aAdresse.IsEmpty() &&
                      adr3.aCodePostal.IsEmpty() && adr3.aVille.IsEmpty());
        }
        break;
      case FORMAT_4:
        {
          TAdresseFormat4 adr4;
          LirePanel(&adr4);
          bEstVide = (adr4.aLieuDit.IsEmpty() && adr4.aNum.IsEmpty() && adr4.aNature.IsEmpty() && adr4.aNomVoie.IsEmpty() &&
                      adr4.aComplement.IsEmpty() && adr4.aBP.IsEmpty() &&
                      adr4.aCodePostal.IsEmpty() && adr4.aVille.IsEmpty());
        }
        break;
      case FORMAT_TDFC:
        {
          TAdresseFormatTDFC adrTDFC;
          LirePanel(&adrTDFC);
          bEstVide = (adrTDFC.aLieuDit.IsEmpty() && adrTDFC.aComplement.IsEmpty() &&
                      adrTDFC.aNum.IsEmpty() && adrTDFC.aNature.IsEmpty() && adrTDFC.aNomVoie.IsEmpty() &&
                      adrTDFC.aBP.IsEmpty() && adrTDFC.aCodePostal.IsEmpty() && adrTDFC.aVille.IsEmpty());
        }
        break;
    }
  }
  catch(Exception &e)
  {
    bEstVide = true;
    EICDisplayException(TAG(1135), e);
  }
  return bEstVide;
}

/***  Fonctions internes ***/
//---------------------------------------------------------------------------
// Fonction permettant de masquer ou d'afficher les libellés du CAdressePanel
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::SetAfficheLibelle(bool b)
{
  try
  {
    if(m_bAfficheLibelle != b)
    {
      m_bAfficheLibelle = b;
      Affichage();
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1140), e);
  }
}
//-------------------------------------------------------------------------------
// Fonction permettant de mettre à Enabled tous les composants du CAdressePanel
//-------------------------------------------------------------------------------
void __fastcall CAdressePanel::SetEnabled( bool b )
{
  try
  {
    if(m_bEnabled != b)
    {
      m_bEnabled = b;
      switch(m_nFormat)
      {
        case FORMAT_1 :
          if(m_bAfficheLibelle)
          {
            Label1->Enabled  = m_bEnabled;
            Label2->Enabled  = m_bEnabled;
            Label3->Enabled  = m_bEnabled;
            Label4->Enabled  = m_bEnabled;
          }
          Edit1->Enabled  = m_bEnabled;
          Edit2->Enabled  = m_bEnabled;
          Edit3->Enabled  = m_bEnabled;
          eCP->Enabled    = m_bEnabled;
          Edit4->Enabled  = m_bEnabled;
          break;
        case FORMAT_2 :
          if(m_bAfficheLibelle)
          {
            Label1->Enabled  = m_bEnabled;
            Label2->Enabled  = m_bEnabled;
            Label3->Enabled  = m_bEnabled;
            Label4->Enabled  = m_bEnabled;
          }
          Edit1->Enabled  = m_bEnabled;
          Edit2->Enabled  = m_bEnabled;
          cbBis->Enabled  = m_bEnabled;
          Edit3->Enabled  = m_bEnabled;
          Edit4->Enabled  = m_bEnabled;
          eCP->Enabled    = m_bEnabled;
          Edit5->Enabled  = m_bEnabled;
          break;
        case FORMAT_3 :
          if(m_bAfficheLibelle)
          {
            Label1->Enabled  = m_bEnabled;
            Label2->Enabled  = m_bEnabled;
            Label3->Enabled  = m_bEnabled;
            Label4->Enabled  = m_bEnabled;
            Label5->Enabled  = m_bEnabled;
            Label6->Enabled  = m_bEnabled;
            Label7->Enabled  = m_bEnabled;
          }
          Edit1->Enabled  = m_bEnabled;
          Edit2->Enabled  = m_bEnabled;
          Edit3->Enabled  = m_bEnabled;
          Edit4->Enabled  = m_bEnabled;
          Edit5->Enabled  = m_bEnabled;
          Edit6->Enabled  = m_bEnabled;
          eCP->Enabled    = m_bEnabled;
          Edit7->Enabled  = m_bEnabled;
          break;
        case FORMAT_4 :
          if(m_bAfficheLibelle)
          {
            Label1->Enabled  = m_bEnabled;
            Label2->Enabled  = m_bEnabled;
            Label3->Enabled  = m_bEnabled;
            Label4->Enabled  = m_bEnabled;
          }
          Edit1->Enabled  = m_bEnabled;
          Edit2->Enabled  = m_bEnabled;
          cbBis->Enabled  = m_bEnabled;
          Edit3->Enabled  = m_bEnabled;
          Edit4->Enabled  = m_bEnabled;
          Edit5->Enabled  = m_bEnabled;
          eCP->Enabled    = m_bEnabled;
          Edit6->Enabled  = m_bEnabled;
          break;
        case FORMAT_TDFC :
          if(m_bAfficheLibelle)
          {
            Label1->Enabled  = m_bEnabled;
            Label2->Enabled  = m_bEnabled;
            Label3->Enabled  = m_bEnabled;
            Label5->Enabled  = m_bEnabled;
            Label6->Enabled  = m_bEnabled;
            if(m_bFormatTDFCacPays)
            {
              Label7->Enabled  = m_bEnabled;
              Label8->Enabled  = m_bEnabled;
            }
          }
          Edit1->Enabled  = m_bEnabled;
          Edit2->Enabled  = m_bEnabled;
          Edit3->Enabled  = m_bEnabled;
          cbBis->Enabled  = m_bEnabled;
          Edit4->Enabled  = m_bEnabled;
          Edit5->Enabled  = m_bEnabled;
          eCP->Enabled    = m_bEnabled;
          Edit6->Enabled  = m_bEnabled;
          if(m_bFormatTDFCacPays)
          {
            cbPays->Enabled = m_bEnabled;
            Edit7->Enabled  = m_bEnabled;
          }
          break;
        default :
          ASSERT(false);
          break;
      }
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1141), e);
  }
}
//-------------------------------------------------------------------------------
// Fonction permettant de mettre à ReadOnly tous les composants du CAdressePanel
//-------------------------------------------------------------------------------
void __fastcall CAdressePanel::SetReadOnly( bool b )
{
  try
  {
    if(m_bReadOnly != b)
    {
      m_bReadOnly = b;
      switch(m_nFormat)
      {
        case FORMAT_1 :
          Edit1->ReadOnly  = m_bReadOnly;
          Edit2->ReadOnly  = m_bReadOnly;
          Edit3->ReadOnly  = m_bReadOnly;
          eCP->ReadOnly    = m_bReadOnly;
          Edit4->ReadOnly  = m_bReadOnly;
          break;
        case FORMAT_2 :
          Edit1->ReadOnly  = m_bReadOnly;
          Edit2->ReadOnly  = m_bReadOnly;
          cbBis->ReadOnly  = m_bReadOnly;
          Edit3->ReadOnly  = m_bReadOnly;
          Edit4->ReadOnly  = m_bReadOnly;
          eCP->ReadOnly    = m_bReadOnly;
          Edit5->ReadOnly  = m_bReadOnly;
          break;
        case FORMAT_3 :
          Edit1->ReadOnly  = m_bReadOnly;
          Edit2->ReadOnly  = m_bReadOnly;
          Edit3->ReadOnly  = m_bReadOnly;
          Edit4->ReadOnly  = m_bReadOnly;
          Edit5->ReadOnly  = m_bReadOnly;
          Edit6->ReadOnly  = m_bReadOnly;
          eCP->ReadOnly    = m_bReadOnly;
          Edit7->ReadOnly  = m_bReadOnly;
          break;
        case FORMAT_4 :
          Edit1->ReadOnly  = m_bReadOnly;
          Edit2->ReadOnly  = m_bReadOnly;
          cbBis->ReadOnly  = m_bReadOnly;
          Edit3->ReadOnly  = m_bReadOnly;
          Edit4->ReadOnly  = m_bReadOnly;
          Edit5->ReadOnly  = m_bReadOnly;
          eCP->ReadOnly    = m_bReadOnly;
          Edit6->ReadOnly  = m_bReadOnly;
          break;
        case FORMAT_TDFC :
          Edit1->ReadOnly  = m_bReadOnly;
          Edit2->ReadOnly  = m_bReadOnly;
          Edit3->ReadOnly  = m_bReadOnly;
          cbBis->ReadOnly  = m_bReadOnly;
          Edit4->ReadOnly  = m_bReadOnly;
          Edit5->ReadOnly  = m_bReadOnly;
          eCP->ReadOnly    = m_bReadOnly;
          Edit6->ReadOnly  = m_bReadOnly;
          if(m_bFormatTDFCacPays)
            cbPays->ReadOnly = m_bReadOnly;
          break;
        default :
          ASSERT(false);
          break;
      }
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1142), e);
  }
}
//---------------------------------------------------------------------------
//     Fonction de création de la CComboBox "cbPays" pour le format TDFC
//       à l'aide d'une liste de Pays prédéfinis selon le "TabPays[]"
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::CreationCbPays(void)
{
TListePays cListePays;
  try
  {
    //Création de la ComboBox "cbPays"
    cbPays          = new CComboBox(this);
    cbPays->Parent  = this;
    // Remplissage de la liste des Pays

    for(int i = 0; i< cListePays.Count; i++)
       cbPays->Items->AddObject(cListePays.TabPays[i].aPays, (TObject*)(cListePays.TabPays[i].iID ));
    cbPays->Sorted = true;
    cbPays->Style = Stdctrls::csDropDownList;
    cbPays->OnChange = cbPaysChange;
    cbPays->TabOrder = 8;
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1150), e);
  }
}

//---------------------------------------------------------------------------
//    Fonction permettant de masquer ou d'afficher la CComboBox "cbPays"
//      et le Code ISO 3166 associé dans le format TDFC ... UNIQUEMENT
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::SetFormatTDFCacPays(bool b)
{
  try
  {
    if(m_bFormatTDFCacPays != b)
    {
      m_bFormatTDFCacPays = b;
      if(m_bFormatTDFCacPays && m_nFormat == FORMAT_TDFC)
      {
        CreationCbPays();
        if(!Edit7)
        {
          Edit7  = new CEdit(this);
          Edit7->Parent = this;
        }
        eCP->CPInternational = true;
      }
      else if(!m_bFormatTDFCacPays && m_nFormat == FORMAT_TDFC)
      {
        delete cbPays;
        cbPays = NULL;
        if(Edit7)
        {
          delete Edit7;
          Edit7 = NULL;
        }
        eCP->CPInternational = false;
      }
      Affichage();
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1160), e);
  }
}

//---------------------------------------------------------------------------
// Fonction permettant d'affecter le code ISO des format concerné suivant le
//           Pays sélectionné (Evènement OnChange de "cbPays")
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::cbPaysChange(TObject *Sender)
{
TListePays cListePays;
  try
  {
    if(m_nFormat == FORMAT_TDFC)
    {
      if( ((CComboBox*)Sender)->ItemIndex != - 1 )
        //Edit7->Text = cListePays.TabPays[((CComboBox*)Sender)->ItemIndex].aCodeISO;
      {
          for(int index = 0; index<  cListePays.Count; index++)
            if (cListePays.TabPays[index].aPays == ((CComboBox*)Sender)->Items->Strings[((CComboBox*)Sender)->ItemIndex])
            {
              Edit7->Text = cListePays.TabPays[index].aCodeISO;
              break;
            }
      }
      else
        Edit7->Text = EmptyStr;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1170), e);
  }
}

//---------------------------------------------------------------------------
void __fastcall CAdressePanel::SetTypeFormat(TYPE_FORMAT f)
{
  int i;
  try
  {
    SuppressionEdit();

    delete cbBis;
    cbBis = NULL;
    delete cbPays;
    cbPays = NULL;
    m_nFormat = f;

    switch(m_nFormat)
    {
      case FORMAT_1 :
        CreationEdit(4);
        Edit4->CharCase = ecUpperCase;
        eCP->TabOrder = 3;
        eCP->CPInternational = false;
        break;
      case FORMAT_2 :
        CreationEdit(5);
        Edit5->CharCase = ecUpperCase;
        cbBis           = new CComboBox(this);
        cbBis->Parent   = this;
        for (enum eComplementNoVoie i = ecnv_FIRST;i <= ecnv_LAST;i++)
          cbBis->Items->Add(LowerCase(lstTypeBis[i]));
/*        cbBis->Items->Add(EmptyStr);
        for(i = 0; *lstTypeBis[i] != '\0'; i++)
          cbBis->Items->Add(LowerCase(lstTypeBis[i]));*/
        cbBis->Style = Stdctrls::csDropDownList;
        cbBis->TabOrder = 3;
        eCP->TabOrder   = 5;
        eCP->CPInternational = false;
        break;
      case FORMAT_3 :
        CreationEdit(7);
        Edit7->CharCase = ecUpperCase;
        eCP->TabOrder = 6;
        eCP->CPInternational = false;
        break;
      case FORMAT_4 :
        CreationEdit(6);
        Edit6->CharCase = ecUpperCase;
        cbBis           = new CComboBox(this);
        cbBis->Parent   = this;
        for (enum eComplementNoVoie i = ecnv_FIRST;i <= ecnv_LAST;i++)
          cbBis->Items->Add(LowerCase(lstTypeBis[i]));
/*        cbBis->Items->Add(EmptyStr);
        for(i = 0; *lstTypeBis[i] != '\0'; i++)
          cbBis->Items->Add(LowerCase(lstTypeBis[i]));*/
        cbBis->Style = Stdctrls::csDropDownList;
        cbBis->TabOrder = 3;
        eCP->TabOrder   = 6;
        eCP->CPInternational = false;
        break;
      case FORMAT_TDFC :
        if(m_bFormatTDFCacPays)
          CreationEdit(7);
        else
          CreationEdit(6);
        Edit6->CharCase = ecUpperCase;
        cbBis           = new CComboBox(this);
        cbBis->Parent   = this;
        for (enum eComplementNoVoie i = ecnv_FIRST;i <= ecnv_LAST;i++)
          cbBis->Items->Add(LowerCase(lstTypeBis[i]));
/*        cbBis->Items->Add(EmptyStr);
        for(i = 0; *lstTypeBis[i] != '\0'; i++)
          cbBis->Items->Add(LowerCase(lstTypeBis[i]));*/
        cbBis->Style = Stdctrls::csDropDownList;
        cbBis->TabOrder = 4;
        if(m_bFormatTDFCacPays)
        {
          CreationCbPays();
          eCP->CPInternational = true;
        }
        else
          eCP->CPInternational = false;
        eCP->TabOrder   = 6;
        break;
      default :
        ASSERT(false);
        break;
    }
    Affichage();
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1180), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::MyResize(TObject *Sender)
{
  try
  {
    Affichage();
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1190), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::MyCanResize(TObject *Sender, int &NewWidth, int &NewHeight, bool &Resize)
{
  struct TTailleMini
  {
    int Height;
    int Width;
  };

  //Tailles minimum AVEC les libellés
  TTailleMini TabTailleMini[] = {{ 85, 195}, //Format 1
                                 { 90, 195}, //Format 2
                                 {110, 243}, //Format 3
                                 { 90, 195}, //Format 4 ou Format TDFC sans Pays
                                 {110, 243}}; //Format TDFC avec Pays

  unsigned short BordEstime;
  int WidthMin;
  int HeightMin;
  int nTailleLibelle;
  int ID_TabTailleMini;

  try
  {
    ID_TabTailleMini = (m_nFormat == FORMAT_TDFC && !m_bFormatTDFCacPays) ? FORMAT_4
                                                                          : m_nFormat;
    if(!m_bAfficheLibelle)
       nTailleLibelle = 0;
    else
      {
      switch(m_nFormat)
         {
         case FORMAT_1 :
         case FORMAT_2 :
         case FORMAT_4 :
         case FORMAT_TDFC :
           nTailleLibelle = 105;
           break;
         case FORMAT_3 :
           nTailleLibelle = 57;
           break;
         default :
           ASSERT(false);
           break;
         }
      }

    BordEstime  = GetBord(NewWidth, NewHeight);

    WidthMin    = nTailleLibelle + TabTailleMini[ID_TabTailleMini].Width + BordEstime*2;
    HeightMin   = TabTailleMini[ID_TabTailleMini].Height + BordEstime*2;

    if(NewWidth < WidthMin)
      NewWidth = WidthMin;

    if(NewHeight < HeightMin)
      NewHeight = HeightMin;

    if (NewWidth == Width && NewHeight == Height)
      Resize = false;
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1200), e);
  }
}

//---------------------------------------------------------------------------
// Fonctions d'affichage des Edits et des Labels selon le format sélectionné
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::Affichage()
{
  try
  {
    switch(m_nFormat)
    {
      case FORMAT_1 :
        AffichageFormat1();
        break;
      case FORMAT_2 :
        AffichageFormat2();
        break;
      case FORMAT_3 :
        AffichageFormat3();
        break;
      case FORMAT_4 :
        AffichageFormat4();
        break;
      case FORMAT_TDFC :
        AffichageFormatTDFC();
        break;
      default :
        ASSERT(false);
        break;
    }
    InitTabOrder();
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1210), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::AffichageFormat1()
{
  unsigned short Bord;
  try
  {
    Bord = GetBord(Width, Height);
    OnCanResize = NULL;

    SuppressionLabel();
    if(m_bAfficheLibelle)
    {
      Label1 = new TLabel(this);
      Label2 = new TLabel(this);
      Label3 = new TLabel(this);
      Label4 = new TLabel(this);

      Label1->Parent  = this;
      Label2->Parent  = this;
      Label3->Parent  = this;
      Label4->Parent  = this;

      Label1->Caption = "Lieu dit";
      Label2->Caption = "N°, b/t et nom voie";
      Label3->Caption = "Complément";
      Label4->Caption = "CP / Ville";

      nTailleLabel = Label1->Width;
      if (Label2->Width > nTailleLabel) nTailleLabel = Label2->Width;
      if (Label3->Width > nTailleLabel) nTailleLabel = Label3->Width;
      if (Label4->Width > nTailleLabel) nTailleLabel = Label4->Width;
    }
    else
      nTailleLabel = 0;

    if(m_bAfficheLibelle)
    {
      Label1->Top   = Bord + 4;
      Label1->Left  = Bord;
      Label1->Width = nTailleLabel;
    }

    Edit1->Top   = Bord;
    Edit1->Left  = Bord + ((m_bAfficheLibelle) ? ( nTailleLabel + ESPACEMENT_DEBUT) : 0);
    Edit1->Width = GET_WIDTH_D(Edit1);

    if(m_bAfficheLibelle)
    {
      Label2->Top   = HEIGHT_CEDIT + (Bord * 2) + 4;
      Label2->Left  = Bord;
      Label2->Width = nTailleLabel;
    }

    Edit2->Top   = HEIGHT_CEDIT + (Bord * 2);
    Edit2->Left  = Edit1->Left;
    Edit2->Width = GET_WIDTH_D(Edit2);

    if(m_bAfficheLibelle)
    {
      Label3->Top   = (HEIGHT_CEDIT * 2) + (Bord * 3) + 4;
      Label3->Left  = Bord;
      Label3->Width = nTailleLabel;
    }

    Edit3->Top   = (HEIGHT_CEDIT * 2) + (Bord * 3);
    Edit3->Left  = Edit1->Left;
    Edit3->Width = GET_WIDTH_D(Edit3);

    if(m_bAfficheLibelle)
    {
      Label4->Top   = (HEIGHT_CEDIT * 3) +(Bord * 4) + 4;
      Label4->Left  = Bord;
      Label4->Width = nTailleLabel;
    }

    eCP->Top   = (HEIGHT_CEDIT * 3) + (Bord * 4);
    eCP->Left  = Edit1->Left;
    eCP->Width = 40;

    Edit4->Top   = (HEIGHT_CEDIT * 3) + (Bord * 4);
    Edit4->Left  = GET_RIGHT(eCP) + ESPACEMENT_ED_ED;
    Edit4->Width = GET_WIDTH_D(Edit4);

    OnCanResize = MyCanResize;
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1220), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::AffichageFormat2()
{
  unsigned short Bord;
  try
  {
    Bord = GetBord(Width, Height);
    OnCanResize = NULL;

    SuppressionLabel();
    if(m_bAfficheLibelle)
    {
      Label1 = new TLabel(this);
      Label2 = new TLabel(this);
      Label3 = new TLabel(this);
      Label4 = new TLabel(this);

      Label1->Parent  = this;
      Label2->Parent  = this;
      Label3->Parent  = this;
      Label4->Parent  = this;

      Label1->Caption = "Lieu dit";
      Label2->Caption = "N°, b/t et nom voie";
      Label3->Caption = "Complément";
      Label4->Caption = "CP / Ville";

      nTailleLabel = Label1->Width;
      if (Label2->Width > nTailleLabel) nTailleLabel = Label2->Width;
      if (Label3->Width > nTailleLabel) nTailleLabel = Label3->Width;
      if (Label4->Width > nTailleLabel) nTailleLabel = Label4->Width;
    }
    else
      nTailleLabel = 0;

    if(m_bAfficheLibelle)
    {
      Label1->Top     = Bord + 4;
      Label1->Left    = Bord;
      Label1->Width   = nTailleLabel;
    }

    Edit1->Top      = Bord;
    Edit1->Left     = Bord + ((m_bAfficheLibelle) ? ( nTailleLabel + ESPACEMENT_DEBUT) : 0);
    Edit1->Width    = GET_WIDTH_D(Edit1);

    if(m_bAfficheLibelle)
    {
      Label2->Top     = HEIGHT_CEDIT + (Bord * 2) + 4;
      Label2->Left    = Bord;
      Label2->Width   = nTailleLabel;
    }

    Edit2->Top       = HEIGHT_CEDIT + (Bord * 2);
    Edit2->Left      = Edit1->Left;
    Edit2->Width     = 40;
    Edit2->MaxLength = 5;

    cbBis->Top      = HEIGHT_CEDIT + (Bord * 2);
    cbBis->Left     = GET_RIGHT(Edit2) + ESPACEMENT_ED_ED;
    cbBis->Width    = 50;

    Edit3->Top      = HEIGHT_CEDIT + (Bord * 2);
    Edit3->Left     = GET_RIGHT(cbBis) + ESPACEMENT_ED_ED;
    Edit3->Width    = GET_WIDTH_D(Edit3);

    if(m_bAfficheLibelle)
    {
      Label3->Top     = (HEIGHT_CEDIT * 2) + (Bord * 3) + 4;
      Label3->Left    = Bord;
      Label3->Width   = nTailleLabel;
    }

    Edit4->Top      = (HEIGHT_CEDIT * 2) + (Bord * 3);
    Edit4->Left     = Edit1->Left;
    Edit4->Width    = GET_WIDTH_D(Edit4);

    if(m_bAfficheLibelle)
    {
      Label4->Top     = (HEIGHT_CEDIT * 3) +(Bord * 4) + 4;
      Label4->Left    = Bord;
      Label4->Width   = nTailleLabel;
    }

    eCP->Top      = (HEIGHT_CEDIT * 3) + (Bord * 4);
    eCP->Left     = Edit1->Left;
    eCP->Width    = 40;

    Edit5->Top      = (HEIGHT_CEDIT * 3) + (Bord * 4);
    Edit5->Left     = GET_RIGHT(eCP) + ESPACEMENT_ED_ED;
    Edit5->Width    = GET_WIDTH_D(Edit5);

    OnCanResize = MyCanResize;
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1230), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::AffichageFormat3()
{
  unsigned short Bord;
  try
  {
    Bord = GetBord(Width, Height);
    OnCanResize = NULL;

    SuppressionLabel();
    if(m_bAfficheLibelle)
    {
      Label1 = new TLabel(this);
      Label2 = new TLabel(this);
      Label3 = new TLabel(this);
      Label4 = new TLabel(this);
      Label5 = new TLabel(this);
      Label6 = new TLabel(this);
      Label7 = new TLabel(this);

      Label1->Parent  = this;
      Label2->Parent  = this;
      Label3->Parent  = this;
      Label4->Parent  = this;
      Label5->Parent  = this;
      Label6->Parent  = this;
      Label7->Parent  = this;

      Label1->Caption = "Résidence";
      Label2->Caption = "Bâtiment";
      Label3->Caption = "Escalier";
      Label4->Caption = "Etage";
      Label5->Caption = "N° de lot";
      Label6->Caption = "Adresse";
      Label7->Caption = "CP / Ville";

      //Pour acoller le label à l'edit associé
      Label3->Alignment = taRightJustify;
      Label4->Alignment = taRightJustify;

      nTailleLabel = Label1->Width;
      if (Label2->Width > nTailleLabel) nTailleLabel = Label2->Width;
      if (Label3->Width > nTailleLabel) nTailleLabel = Label3->Width;
      if (Label4->Width > nTailleLabel) nTailleLabel = Label4->Width;
      if (Label5->Width > nTailleLabel) nTailleLabel = Label5->Width;
      if (Label6->Width > nTailleLabel) nTailleLabel = Label6->Width;
      if (Label7->Width > nTailleLabel) nTailleLabel = Label7->Width;
    }
    else
      nTailleLabel = 0;

    if(m_bAfficheLibelle)
    {
      Label1->Top     = Bord + 4;
      Label1->Left    = Bord;
      Label1->Width   = nTailleLabel;
    }

    Edit1->Top      = Bord;
    Edit1->Left     = Bord + nTailleLabel + ESPACEMENT_LAB_ED;
    Edit1->Width    = Width - Edit1->Left - Bord; //Cet edit prend toute la largeur

    if(m_bAfficheLibelle)
    {
      Label2->Top     = HEIGHT_CEDIT + (Bord * 2) + 4;
      Label2->Left    = Bord;
      Label2->Width   = nTailleLabel;
    }

    Edit2->Top      = HEIGHT_CEDIT + (Bord * 2);
    Edit2->Left     = Edit1->Left;
    Edit2->Width    = 50;

    /// Positionne la zone "Etage" à droite
    //////////////////////////////////////////////////////////////////////////
    Edit4->Top      = Edit2->Top;
    Edit4->Width    = 25;
    Edit4->Left     = GET_RIGHT(Edit1) - Edit4->Width;

    if(m_bAfficheLibelle)
    {
      Label4->Top     = HEIGHT_CEDIT + (Bord * 2) + 4;
      Label4->Left    = Edit4->Left - Label4->Width - ESPACEMENT_LAB_ED;
    }

    /// Positionne la zone "Escalier" à égale distance de "Bâtiment" et "étage"
    //////////////////////////////////////////////////////////////////////////
    Edit3->Top      = Edit2->Top;
    Edit3->Left     = GET_RIGHT(Edit2) + ((Label4 ? Label4->Left : Edit4->Left) - GET_RIGHT(Edit2))/2;
    Edit3->Width    = 50;

    if(m_bAfficheLibelle)
    {
      Label3->Top     = HEIGHT_CEDIT + (Bord * 2) + 4;
      Label3->Left    = Edit3->Left - Label3->Width - ESPACEMENT_LAB_ED;
    }

    if(m_bAfficheLibelle)
    {
      Label5->Top     = (HEIGHT_CEDIT * 2) + (Bord * 3) + 4;
      Label5->Left    = Bord;
      Label5->Width   = nTailleLabel;
    }

    Edit5->Top      = (HEIGHT_CEDIT * 2) + (Bord * 3);
    Edit5->Left     = Edit1->Left;
    Edit5->Width    = 30;

    if(m_bAfficheLibelle)
    {
      Label6->Top     = (HEIGHT_CEDIT * 3) + (Bord * 4) + 4;
      Label6->Left    = Bord;
      Label6->Width   = nTailleLabel;
    }

    Edit6->Top      = (HEIGHT_CEDIT * 3) + (Bord * 4);
    Edit6->Left     = Edit1->Left;
    Edit6->Width    = Width - Edit6->Left - Bord;

    if(m_bAfficheLibelle)
    {
      Label7->Top     = (HEIGHT_CEDIT * 4) +(Bord * 5) + 4;
      Label7->Left    = Bord;
      Label7->Width   = nTailleLabel;
    }

    eCP->Top      = (HEIGHT_CEDIT * 4) + (Bord * 5);
    eCP->Left     = Edit1->Left;
    eCP->Width    = 40;

    Edit7->Top      = eCP->Top;
    Edit7->Left     = GET_RIGHT(eCP) + ESPACEMENT_ED_ED;
    Edit7->Width    = Width - Bord - Edit7->Left;

    OnCanResize = MyCanResize;
  }catch(Exception &e)
  {
    EICDisplayException(TAG(1240), e);
  }
}

//---------------------------------------------------------------------------
void __fastcall CAdressePanel::AffichageFormat4()
{
  unsigned short Bord;
  try
  {
    Bord = GetBord(Width, Height);
    OnCanResize = NULL;

    SuppressionLabel();
    if(m_bAfficheLibelle)
    {
      Label1 = new TLabel(this);
      Label2 = new TLabel(this);
      Label3 = new TLabel(this);
      Label4 = new TLabel(this);

      Label1->Parent  = this;
      Label2->Parent  = this;
      Label3->Parent  = this;
      Label4->Parent  = this;

      Label1->Caption = "Lieu dit";
      Label2->Caption = "N°, b/t et nom voie";
      Label3->Caption = "BP / Complément";
      Label4->Caption = "CP / Ville";

      nTailleLabel = Label1->Width;
      if (Label2->Width > nTailleLabel) nTailleLabel = Label2->Width;
      if (Label3->Width > nTailleLabel) nTailleLabel = Label3->Width;
      if (Label4->Width > nTailleLabel) nTailleLabel = Label4->Width;
    }
    else
      nTailleLabel = 0;

    if(m_bAfficheLibelle)
    {
      Label1->Top     = Bord + 4;
      Label1->Left    = Bord;
      Label1->Width   = nTailleLabel;
    }

    Edit1->Top      = Bord;
    Edit1->Left     = Bord + ((m_bAfficheLibelle) ? ( nTailleLabel + ESPACEMENT_DEBUT) : 0);
    Edit1->Width    = GET_WIDTH_D(Edit1);

    if(m_bAfficheLibelle)
    {
      Label2->Top     = HEIGHT_CEDIT + (Bord * 2) + 4;
      Label2->Left    = Bord;
      Label2->Width   = nTailleLabel;
    }

    Edit2->Top          = HEIGHT_CEDIT + (Bord * 2);
    Edit2->Left         = Edit1->Left;
    Edit2->Width        = 40;
    Edit2->MaxLength    = 5;

    cbBis->Top      = HEIGHT_CEDIT + (Bord * 2);
    cbBis->Left     = GET_RIGHT(Edit2) + ESPACEMENT_ED_ED;
    cbBis->Width    = 50;

    Edit3->Top      = HEIGHT_CEDIT + (Bord * 2);
    Edit3->Left     = GET_RIGHT(cbBis) + ESPACEMENT_ED_ED;
    Edit3->Width    = Width - Edit3->Left - Bord;

    if(m_bAfficheLibelle)
    {
      Label3->Top     = (HEIGHT_CEDIT * 2) + (Bord * 3) + 4;
      Label3->Left    = Bord;
      Label3->Width   = nTailleLabel;
    }

    Edit4->Top      = (HEIGHT_CEDIT * 2) + (Bord * 3);
    Edit4->Left     = Edit1->Left;
    Edit4->Width    = 40;

    Edit5->Top      = (HEIGHT_CEDIT * 2) + (Bord * 3);
    Edit5->Left     = GET_RIGHT(Edit4) + ESPACEMENT_ED_ED;
    Edit5->Width    = GET_WIDTH_D(Edit5);

    if(m_bAfficheLibelle)
    {
      Label4->Top     = (HEIGHT_CEDIT * 3) +(Bord * 4) + 4;
      Label4->Left    = Bord;
      Label4->Width   = nTailleLabel;
    }

    eCP->Top      = (HEIGHT_CEDIT * 3) + (Bord * 4);
    eCP->Left     = Edit1->Left;
    eCP->Width    = 40;

    Edit6->Top      = (HEIGHT_CEDIT * 3) + (Bord * 4);
    Edit6->Left     = GET_RIGHT(eCP) + ESPACEMENT_ED_ED;
    Edit6->Width    = GET_WIDTH_D(Edit6);

    OnCanResize = MyCanResize;
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1250), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::AffichageFormatTDFC()
{
  unsigned short Bord;
  try
  {
    Bord = GetBord(Width, Height);
    OnCanResize = NULL;

    SuppressionLabel();
    if(m_bAfficheLibelle)
    {
      Label1 = new TLabel(this);
      Label2 = new TLabel(this);
      Label3 = new TLabel(this);
      Label5 = new TLabel(this);
      Label6 = new TLabel(this);

      Label1->Parent  = this;
      Label2->Parent  = this;
      Label3->Parent  = this;
      Label5->Parent  = this;
      Label6->Parent  = this;

      Label1->Caption = "Lieu dit";
      Label2->Caption = "Complément";
      Label3->Caption = "N°, b/t et nom voie";
      Label5->Caption = "BP";
      Label6->Caption = "CP / Ville";

      if(m_bFormatTDFCacPays)
      {
        Label7 = new TLabel(this);
        Label8 = new TLabel(this);
        Label7->Parent  = this;
        Label8->Parent  = this;
        Label7->Caption = "Pays";
        Label8->Caption = "Code ISO";
      }

      nTailleLabel = Label1->Width;
      if (Label2->Width > nTailleLabel) nTailleLabel = Label2->Width;
      if (Label3->Width > nTailleLabel) nTailleLabel = Label3->Width;
      if (Label5->Width > nTailleLabel) nTailleLabel = Label5->Width;
      if (Label6->Width > nTailleLabel) nTailleLabel = Label6->Width;
      if(m_bFormatTDFCacPays)
      {
        if (Label7->Width > nTailleLabel) nTailleLabel = Label7->Width;
        if (Label8->Width > nTailleLabel) nTailleLabel = Label8->Width;
      }

    }
    else
      nTailleLabel = 0;

    if(m_bAfficheLibelle)
    {
      Label1->Top     = Bord + 4;
      Label1->Left    = Bord;
      Label1->Width   = nTailleLabel;
    }

    Edit1->Top       = Bord;
    Edit1->Left      = Bord + ((m_bAfficheLibelle) ? ( nTailleLabel + ESPACEMENT_DEBUT) : 0);
    Edit1->Width     = GET_WIDTH_D(Edit1);
    Edit1->MaxLength = 35;

    if(m_bAfficheLibelle)
    {
      Label2->Top     = HEIGHT_CEDIT + (Bord * 2) + 4;
      Label2->Left    = Bord;
      Label2->Width   = nTailleLabel;
    }

    Edit2->Top       = HEIGHT_CEDIT + (Bord * 2);
    Edit2->Left      = Edit1->Left;
    Edit2->Width     = GET_WIDTH_D(Edit2);
    Edit2->MaxLength = 35;

    if(m_bAfficheLibelle)
    {
      Label3->Top     = (HEIGHT_CEDIT * 2) + (Bord * 3) + 4;
      Label3->Left    = Bord;
      Label3->Width   = nTailleLabel;
    }

    Edit3->Top       = (HEIGHT_CEDIT * 2) + (Bord * 3);
    Edit3->Left      = Edit1->Left;
    Edit3->Width     = 40;
    Edit3->MaxLength = 4;

    cbBis->Top      = (HEIGHT_CEDIT * 2) + (Bord * 3);
    cbBis->Left     = GET_RIGHT(Edit3) + ESPACEMENT_ED_ED;
    cbBis->Width    = 50;

    /// Positionne la zone "BP" à droite
    //////////////////////////////////////////////////////////////////////////
    Edit5->Top       = Edit3->Top;
    Edit5->Width     = 40;
    Edit5->Left      = GET_RIGHT(Edit1) - Edit5->Width;
    Edit5->MaxLength = 5;

    if(m_bAfficheLibelle)
    {
      Label5->Top     = (HEIGHT_CEDIT * 2) + (Bord * 3) + 4;
      Label5->Left    = Edit5->Left - Label5->Width - ESPACEMENT_LAB_ED;
    }

    Edit4->Top      = (HEIGHT_CEDIT * 2) + (Bord * 3);
    Edit4->Left     = GET_RIGHT(cbBis) + ESPACEMENT_ED_ED;
    Edit4->MaxLength = 30;
    if(m_bAfficheLibelle)
      Edit4->Width  = Label5->Left - Edit4->Left - ESPACEMENT_LAB_ED;
    else
      Edit4->Width  = Edit5->Left - Edit4->Left - ESPACEMENT_ED_ED;

    if(m_bAfficheLibelle)
    {
      Label6->Top     = (HEIGHT_CEDIT * 3) +(Bord * 4) + 4;
      Label6->Left    = Bord;
      Label6->Width   = nTailleLabel;
    }

    eCP->Top      = (HEIGHT_CEDIT * 3) + (Bord * 4);
    eCP->Left     = Edit1->Left;
    eCP->Width    = m_bFormatTDFCacPays ? 110 : 40;

    Edit6->Top      = (HEIGHT_CEDIT * 3) + (Bord * 4);
    Edit6->Left     = GET_RIGHT(eCP) + ESPACEMENT_ED_ED;
    Edit6->Width    = GET_WIDTH_D(Edit6);
    Edit6->MaxLength = 35;

    if(m_bFormatTDFCacPays)
    {
      if(m_bAfficheLibelle)
      {
        Label7->Top     = (HEIGHT_CEDIT * 4) +(Bord * 5) + 4;
        Label7->Left    = Bord;
        Label7->Width   = nTailleLabel;
      }

      /// Positionne la zone "Code ISO" à droite
      //////////////////////////////////////////////////////////////////////////

      Edit7->Top      = (HEIGHT_CEDIT * 4) + (Bord * 5);
      Edit7->Width    = 25;
      Edit7->Left     = GET_RIGHT(Edit1) - Edit7->Width;
      Edit7->ReadOnly = true;

      if(m_bAfficheLibelle)
      {
        Label8->Top     = (HEIGHT_CEDIT * 4) +(Bord * 5) + 4;
        Label8->Left    = Edit7->Left - Label8->Width - ESPACEMENT_LAB_ED;
      }

      cbPays->Top     = (HEIGHT_CEDIT * 4) + (Bord * 5);
      cbPays->Left    = Edit1->Left;
      if(m_bAfficheLibelle)
        cbPays->Width = Label8->Left - cbPays->Left - ESPACEMENT_LAB_ED;
      else
        cbPays->Width = Edit7->Left - cbPays->Left - ESPACEMENT_ED_ED;
    }

    OnCanResize = MyCanResize;
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1260), e);
  }
}

//---------------------------------------------------------------------------
//       Fonction de création des Edits suivant le nb d'édits nécessaire
//                          au format sélectionné
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::CreationEdit(int NbEdit)
{
  try
  {
    switch(NbEdit)
    {
      case 4 :
        Edit1  = new CEdit(this);
        Edit2  = new CEdit(this);
        Edit3  = new CEdit(this);
        Edit4  = new CEdit(this);

        Edit1->Parent = this;
        Edit2->Parent = this;
        Edit3->Parent = this;
        Edit4->Parent = this;
        break;
      case 5 :
        Edit1  = new CEdit(this);
        Edit2  = new CEdit(this);
        Edit3  = new CEdit(this);
        Edit4  = new CEdit(this);
        Edit5  = new CEdit(this);

        Edit1->Parent = this;
        Edit2->Parent = this;
        Edit3->Parent = this;
        Edit4->Parent = this;
        Edit5->Parent = this;
        break;
      case 6 :
        Edit1  = new CEdit(this);
        Edit2  = new CEdit(this);
        Edit3  = new CEdit(this);
        Edit4  = new CEdit(this);
        Edit5  = new CEdit(this);
        Edit6  = new CEdit(this);

        Edit1->Parent = this;
        Edit2->Parent = this;
        Edit3->Parent = this;
        Edit4->Parent = this;
        Edit5->Parent = this;
        Edit6->Parent = this;
        break;
      case 7 :
        Edit1  = new CEdit(this);
        Edit2  = new CEdit(this);
        Edit3  = new CEdit(this);
        Edit4  = new CEdit(this);
        Edit5  = new CEdit(this);
        Edit6  = new CEdit(this);
        Edit7  = new CEdit(this);

        Edit1->Parent = this;
        Edit2->Parent = this;
        Edit3->Parent = this;
        Edit4->Parent = this;
        Edit5->Parent = this;
        Edit6->Parent = this;
        Edit7->Parent = this;
        break;
      default :
        ASSERT(false);
        break;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1270), e);
  }
}

//---------------------------------------------------------------------------
// Fonctions permettant de supprimer les Edits et les Labels du CAdressePanel
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::SuppressionEdit()
{
  try
  {
    OnCanResize = NULL;
    if (Edit1)  { delete Edit1; Edit1 = NULL; }
    if (Edit2)  { delete Edit2; Edit2 = NULL; }
    if (Edit3)  { delete Edit3; Edit3 = NULL; }
    if (Edit4)  { delete Edit4; Edit4 = NULL; }
    if (Edit5)  { delete Edit5; Edit5 = NULL; }
    if (Edit6)  { delete Edit6; Edit6 = NULL; }
    if (Edit7)  { delete Edit7; Edit7 = NULL; }
    if (Edit8)  { delete Edit8; Edit8 = NULL; }
    OnCanResize = MyCanResize;
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1280), e);
  }
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::SuppressionLabel()
{
  try
  {
    OnCanResize = NULL;
    if(Label1) { delete Label1; Label1 = NULL; }
    if(Label2) { delete Label2; Label2 = NULL; }
    if(Label3) { delete Label3; Label3 = NULL; }
    if(Label4) { delete Label4; Label4 = NULL; }
    if(Label5) { delete Label5; Label5 = NULL; }
    if(Label6) { delete Label6; Label6 = NULL; }
    if(Label7) { delete Label7; Label7 = NULL; }
    if(Label8) { delete Label8; Label8 = NULL; }
    OnCanResize = MyCanResize;
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1290), e);
  }
}

//---------------------------------------------------------------------------
//    Fonction permettant de calculer la largeur nécessaire (et identique)
//            entre 2 Edits suivant la hauteur du CAdressePanel
//---------------------------------------------------------------------------
unsigned short __fastcall CAdressePanel::GetBord(int Width, int Height) const
{
  int NbLignes = 0;
  try
  {
    switch(m_nFormat)
    {
      case FORMAT_1    : NbLignes = NB_LIGNES_FORMAT1;     break;
      case FORMAT_2    : NbLignes = NB_LIGNES_FORMAT2;     break;
      case FORMAT_3    : NbLignes = NB_LIGNES_FORMAT3;     break;
      case FORMAT_4    : NbLignes = NB_LIGNES_FORMAT4;     break;
      case FORMAT_TDFC : if(m_bFormatTDFCacPays)
                           NbLignes = NB_LIGNES_FORMAT_TDFC;
                         else
                           NbLignes = NB_LIGNES_FORMAT_TDFC - 1;
                         break;
      default          : ASSERT(false);                    break;
    }
    if(Height < NbLignes * HEIGHT_CEDIT)
      return m_bAfficheLibelle ? 2 : 0;
    else
      return (Height - (NbLignes * HEIGHT_CEDIT)) / (NbLignes + 1);
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1300), e);
  }
  return 0;
}
//---------------------------------------------------------------------------
void __fastcall CAdressePanel::InitTabOrder( void )
{
  try
  {
    switch(m_nFormat)
    {
      case FORMAT_1 :
        Edit1->TabOrder = 0;
        Edit2->TabOrder = 1;
        Edit3->TabOrder = 2;
        eCP->TabOrder   = 3;
        Edit4->TabOrder = 4;
        break;
      case FORMAT_2 :
        Edit1->TabOrder = 0;
        Edit2->TabOrder = 1;
        cbBis->TabOrder = 2;
        Edit3->TabOrder = 3;
        Edit4->TabOrder = 4;
        eCP->TabOrder   = 5;
        Edit5->TabOrder = 6;
        break;
      case FORMAT_3 :
        Edit1->TabOrder = 0;
        Edit2->TabOrder = 1;
        Edit3->TabOrder = 2;
        Edit4->TabOrder = 3;
        Edit5->TabOrder = 4;
        Edit6->TabOrder = 5;
        eCP->TabOrder   = 6;
        Edit7->TabOrder = 7;
        break;
      case FORMAT_4 :
        Edit1->TabOrder = 0;
        Edit2->TabOrder = 1;
        cbBis->TabOrder = 2;
        Edit3->TabOrder = 3;
        Edit4->TabOrder = 4;
        Edit5->TabOrder = 5;
        eCP->TabOrder   = 6;
        Edit6->TabOrder = 7;
        break;
      case FORMAT_TDFC :
        Edit1->TabOrder = 0;
        Edit2->TabOrder = 1;
        Edit3->TabOrder = 2;
        cbBis->TabOrder = 3;
        Edit4->TabOrder = 4;
        Edit5->TabOrder = 5;
        eCP->TabOrder   = 6;
        Edit6->TabOrder = 7;
        if(m_bFormatTDFCacPays)
        {
          cbPays->TabOrder = 8;
          Edit7->TabOrder  = 9;
        }
        break;
      default :
        ASSERT(false);
        break;
    }
  }
  catch(Exception &e)
  {
    EICDisplayException(TAG(1400), e);
  }
}
//---------------------------------------------------------------------------

